Skip to content

Conversation

@calavera
Copy link
Contributor

Issue #, if available:

The discussion in #823 made me think that we can provide much better ergonomics to work with Api Gateway Authorizers, since it looks like a common use case.

Description of changes:

There are changes in the events crate that are not backwards compatible, but I believe they provide much better user experience. I've divided this PR in three commits so you can check the changes out in isolation. There are more details in the commit messages.

By submitting this pull request

  • I confirm that my contribution is made under the terms of the Apache 2.0 license.
  • I confirm that I've made a best effort attempt to update all relevant documentation.

- Remove the generic attribute since the authorizer values are not always of the same type, just use Value.
- Match authorizer type to use the same type for all events.
- Make the authorizer fields match the Java and DotNet implementation, which both use a Map<String, Object> for Rest and WebSocket events.
-- https://github.com/aws/aws-lambda-dotnet/blob/master/Libraries/src/Amazon.Lambda.APIGatewayEvents/APIGatewayProxyRequest.cs
-- https://github.com/aws/aws-lambda-java-libs/blob/main/aws-lambda-java-events/src/main/java/com/amazonaws/services/lambda/runtime/events/APIGatewayV2WebSocketEvent.java#L225

Signed-off-by: David Calavera <david.calavera@gmail.com>
Signed-off-by :David Calavera <david.calavera@gmail.com>
This also shows how to work with the RequestExt trait and the RequestContext object.

Signed-off-by: David Calavera <david.calavera@gmail.com>
@calavera calavera requested a review from bnusunny February 21, 2024 05:20
Copy link
Collaborator

@bnusunny bnusunny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Make the name more consistent since it's used for multiple versions of Api Gateway.
Keep the old names as deprecated.

Signed-off-by: David Calavera <david.calavera@gmail.com>
Signed-off-by: David Calavera <david.calavera@gmail.com>
@calavera calavera merged commit fabffbc into main Feb 21, 2024
@calavera calavera deleted the apigw_authorizer branch February 21, 2024 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants